<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>vue指令小项目1</title>
    <script src="node_modules/vue/dist/vue.js"></script>

    <style>
        #app {
            width: 480px;
            height: 100px;
            margin: 200px auto;
        }
        .input-num {
            margin-top: 20px;
            height: 100%;
            display: flex;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 0 4px black;
        }
        .input-num button {
            width: 150px;
            height: 100%;
            font-size: 40px;
            color: gray;
            cursor: pointer;
            border: none;
            outline: none;
        }
        .input-num span {
            height: 100%;
            font-size: 40px;
            flex: 1;
            text-align: center;
            line-height: 100px;
        }
    </style>

</head>

<body>
<div id="app">
    <!--<img src="http://www.itheima.com/images/logo.png" alt="" />-->
    <div class="input-num">
        <button @click="add"> + </button>
        <!--<h2 v-text="cout"></h2>-->
        <span>{{cout}}</span>
        <button @click="sub"> - </button>
    </div>
</div>

<script type="text/javascript">
    var app = new Vue({
        el:"#app",
        data:{
            cout:1
        },
        methods: {
            add: function () {
                this.cout++;
                if(this.cout>10){
                    alert("以及达到最大值");
                    this.cout = 10 ;
                }
            },
            sub: function () {
                this.cout--;
                if(this.cout<0){
                    alert("以及达到最小值");
                    this.cout = 0 ;
                }
            }
        }
    });
</script>
</body>
</html>